home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1998 November / Freeware November 1998.img / dist / fw_emacs.idb / usr / freeware / info / emacs-10.z / emacs-10 (.txt)
GNU Info File  |  1998-10-27  |  49KB  |  898 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.63 from the
  2. input file emacs.texi.
  3. File: emacs,  Node: Indentation,  Next: Text,  Prev: Major Modes,  Up: Top
  4. Indentation
  5. ***********
  6.    This chapter describes the Emacs commands that add, remove, or
  7. adjust indentation.
  8. `TAB'
  9.      Indent current line "appropriately" in a mode-dependent fashion.
  10. `LFD'
  11.      Perform RET followed by TAB (`newline-and-indent').
  12. `M-^'
  13.      Merge two lines (`delete-indentation').  This would cancel out the
  14.      effect of LFD.
  15. `C-M-o'
  16.      Split line at point; text on the line after point becomes a new
  17.      line indented to the same column that it now starts in
  18.      (`split-line').
  19. `M-m'
  20.      Move (forward or back) to the first nonblank character on the
  21.      current line (`back-to-indentation').
  22. `C-M-\'
  23.      Indent several lines to same column (`indent-region').
  24. `C-x TAB'
  25.      Shift block of lines rigidly right or left (`indent-rigidly').
  26. `M-i'
  27.      Indent from point to the next prespecified tab stop column
  28.      (`tab-to-tab-stop').
  29. `M-x indent-relative'
  30.      Indent from point to under an indentation point in the previous
  31.      line.
  32.    Most programming languages have some indentation convention.  For
  33. Lisp code, lines are indented according to their nesting in
  34. parentheses.  The same general idea is used for C code, though many
  35. details are different.
  36.    Whatever the language, to indent a line, use the TAB command.  Each
  37. major mode defines this command to perform the sort of indentation
  38. appropriate for the particular language.  In Lisp mode, TAB aligns the
  39. line according to its depth in parentheses.  No matter where in the
  40. line you are when you type TAB, it aligns the line as a whole.  In C
  41. mode, TAB implements a subtle and sophisticated indentation style that
  42. knows about many aspects of C syntax.
  43.    In Text mode, TAB runs the command `tab-to-tab-stop', which indents
  44. to the next tab stop column.  You can set the tab stops with `M-x
  45. edit-tab-stops'.
  46. * Menu:
  47. * Indentation Commands::  Various commands and techniques for indentation.
  48. * Tab Stops::             You can set arbitrary "tab stops" and then
  49.                             indent to the next tab stop when you want to.
  50. * Just Spaces::           You can request indentation using just spaces.
  51. File: emacs,  Node: Indentation Commands,  Next: Tab Stops,  Prev: Indentation,  Up: Indentation
  52. Indentation Commands and Techniques
  53. ===================================
  54.    To move over the indentation on a line, do `M-m'
  55. (`back-to-indentation').  This command, given anywhere on a line,
  56. positions point at the first nonblank character on the line.
  57.    To insert an indented line before the current line, do `C-a C-o
  58. TAB'.  To make an indented line after the current line, use `C-e LFD'.
  59.    If you just want to insert a tab character in the buffer, you can
  60. type `C-q TAB'.
  61.    `C-M-o' (`split-line') moves the text from point to the end of the
  62. line vertically down, so that the current line becomes two lines.
  63. `C-M-o' first moves point forward over any spaces and tabs.  Then it
  64. inserts after point a newline and enough indentation to reach the same
  65. column point is on.  Point remains before the inserted newline; in this
  66. regard, `C-M-o' resembles `C-o'.
  67.    To join two lines cleanly, use the `M-^' (`delete-indentation')
  68. command.  It deletes the indentation at the front of the current line,
  69. and the line boundary as well, replacing them with a single space.  As
  70. a special case (useful for Lisp code) the single space is omitted if
  71. the characters to be joined are consecutive open parentheses or closing
  72. parentheses, or if the junction follows another newline.  To delete
  73. just the indentation of a line, go to the beginning of the line and use
  74. `M-\' (`delete-horizontal-space'), which deletes all spaces and tabs
  75. around the cursor.
  76.    If you have a fill prefix, `M-^' deletes the fill prefix if it
  77. appears after the newline that is deleted.  *Note Fill Prefix::.
  78.    There are also commands for changing the indentation of several lines
  79. at once.  `C-M-\' (`indent-region') applies to all the lines that begin
  80. in the region; it indents each line in the "usual" way, as if you had
  81. typed TAB at the beginning of the line.  A numeric argument specifies
  82. the column to indent to, and each line is shifted left or right so that
  83. its first nonblank character appears in that column.  `C-x TAB'
  84. (`indent-rigidly') moves all of the lines in the region right by its
  85. argument (left, for negative arguments).  The whole group of lines
  86. moves rigidly sideways, which is how the command gets its name.
  87.    `M-x indent-relative' indents at point based on the previous line
  88. (actually, the last nonempty line).  It inserts whitespace at point,
  89. moving point, until it is underneath an indentation point in the
  90. previous line.  An indentation point is the end of a sequence of
  91. whitespace or the end of the line.  If point is farther right than any
  92. indentation point in the previous line, the whitespace before point is
  93. deleted and the first indentation point then applicable is used.  If no
  94. indentation point is applicable even then, `indent-relative' runs
  95. `tab-to-tab-stop' (*note Tab Stops::.).
  96.    `indent-relative' is the definition of TAB in Indented Text mode.
  97. *Note Text::.
  98.    *Note Format Indentation::, for another way of specifying the
  99. indentation for part of your text.
  100. File: emacs,  Node: Tab Stops,  Next: Just Spaces,  Prev: Indentation Commands,  Up: Indentation
  101. Tab Stops
  102. =========
  103.    For typing in tables, you can use Text mode's definition of TAB,
  104. `tab-to-tab-stop'.  This command inserts indentation before point,
  105. enough to reach the next tab stop column.  If you are not in Text mode,
  106. this command can be found on the key `M-i'.
  107.    You can specify the tab stops used by `M-i'.  They are stored in a
  108. variable called `tab-stop-list', as a list of column-numbers in
  109. increasing order.
  110.    The convenient way to set the tab stops is with `M-x edit-tab-stops',
  111. which creates and selects a buffer containing a description of the tab
  112. stop settings.  You can edit this buffer to specify different tab
  113. stops, and then type `C-c C-c' to make those new tab stops take effect.
  114. In the tab stop buffer, `C-c C-c' runs the function
  115. `edit-tab-stops-note-changes' rather than its usual definition
  116. `save-buffer'.  `edit-tab-stops' records which buffer was current when
  117. you invoked it, and stores the tab stops back in that buffer; normally
  118. all buffers share the same tab stops and changing them in one buffer
  119. affects all, but if you happen to make `tab-stop-list' local in one
  120. buffer then `edit-tab-stops' in that buffer will edit the local
  121. settings.
  122.    Here is what the text representing the tab stops looks like for
  123. ordinary tab stops every eight columns.
  124.              :       :       :       :       :       :
  125.      0         1         2         3         4
  126.      0123456789012345678901234567890123456789012345678
  127.      To install changes, type C-c C-c
  128.    The first line contains a colon at each tab stop.  The remaining
  129. lines are present just to help you see where the colons are and know
  130. what to do.
  131.    Note that the tab stops that control `tab-to-tab-stop' have nothing
  132. to do with displaying tab characters in the buffer.  *Note Display
  133. Vars::, for more information on that.
  134. File: emacs,  Node: Just Spaces,  Prev: Tab Stops,  Up: Indentation
  135. Tabs vs. Spaces
  136. ===============
  137.    Emacs normally uses both tabs and spaces to indent lines.  If you
  138. prefer, all indentation can be made from spaces only.  To request this,
  139. set `indent-tabs-mode' to `nil'.  This is a per-buffer variable;
  140. altering the variable affects only the current buffer, but there is a
  141. default value which you can change as well.  *Note Locals::.
  142.    There are also commands to convert tabs to spaces or vice versa,
  143. always preserving the columns of all nonblank text.  `M-x tabify' scans
  144. the region for sequences of spaces, and converts sequences of at least
  145. three spaces to tabs if that can be done without changing indentation.
  146. `M-x untabify' changes all tabs in the region to appropriate numbers of
  147. spaces.
  148. File: emacs,  Node: Text,  Next: Programs,  Prev: Indentation,  Up: Top
  149. Commands for Human Languages
  150. ****************************
  151.    The term "text" has two widespread meanings in our area of the
  152. computer field.  One is data that is a sequence of characters.  Any file
  153. that you edit with Emacs is text, in this sense of the word.  The other
  154. meaning is more restrictive: a sequence of characters in a human
  155. language for humans to read (possibly after processing by a text
  156. formatter), as opposed to a program or commands for a program.
  157.    Human languages have syntactic/stylistic conventions that can be
  158. supported or used to advantage by editor commands: conventions involving
  159. words, sentences, paragraphs, and capital letters.  This chapter
  160. describes Emacs commands for all of these things.  There are also
  161. commands for "filling", which means rearranging the lines of a
  162. paragraph to be approximately equal in length.  The commands for moving
  163. over and killing words, sentences and paragraphs, while intended
  164. primarily for editing text, are also often useful for editing programs.
  165.    Emacs has several major modes for editing human language text.  If
  166. the file contains text pure and simple, use Text mode, which customizes
  167. Emacs in small ways for the syntactic conventions of text.  Outline mode
  168. provides special commands for operating on text with an outline
  169. structure.
  170.    For text which contains embedded commands for text formatters, Emacs
  171. has other major modes, each for a particular text formatter.  Thus, for
  172. input to TeX, you would use TeX mode.  For input to nroff, use Nroff
  173. mode.
  174.    Instead of using a text formatter, you can edit formatted text in
  175. WYSIWYG style ("what you see is what you get"), with Enriched mode.
  176. Then the formatting appears on the screen in Emacs while you edit.
  177. * Menu:
  178. * Words::         Moving over and killing words.
  179. * Sentences::     Moving over and killing sentences.
  180. * Paragraphs::      Moving over paragraphs.
  181. * Pages::      Moving over pages.
  182. * Filling::       Filling or justifying text.
  183. * Case::          Changing the case of text.
  184. * Text Mode::     The major modes for editing text files.
  185. * Outline Mode::  The major mode for editing outlines.
  186. * TeX Mode::      The major modes for editing input to the formatter TeX.
  187. * Nroff Mode::    The major mode for editing input to the formatter nroff.
  188. * Formatted Text::Editing formatted text directly in WYSIWYG fashion.
  189. File: emacs,  Node: Words,  Next: Sentences,  Up: Text
  190. Words
  191. =====
  192.    Emacs has commands for moving over or operating on words.  By
  193. convention, the keys for them are all Meta characters.
  194. `M-f'
  195.      Move forward over a word (`forward-word').
  196. `M-b'
  197.      Move backward over a word (`backward-word').
  198. `M-d'
  199.      Kill up to the end of a word (`kill-word').
  200. `M-DEL'
  201.      Kill back to the beginning of a word (`backward-kill-word').
  202. `M-@'
  203.      Mark the end of the next word (`mark-word').
  204. `M-t'
  205.      Transpose two words or drag a word across other words
  206.      (`transpose-words').
  207.    Notice how these keys form a series that parallels the
  208. character-based `C-f', `C-b', `C-d', `C-t' and DEL.  `M-@' is cognate
  209. to `C-@', which is an alias for `C-SPC'.
  210.    The commands `M-f' (`forward-word') and `M-b' (`backward-word') move
  211. forward and backward over words.  These Meta characters are thus
  212. analogous to the corresponding control characters, `C-f' and `C-b',
  213. which move over single characters in the text.  The analogy extends to
  214. numeric arguments, which serve as repeat counts.  `M-f' with a negative
  215. argument moves backward, and `M-b' with a negative argument moves
  216. forward.  Forward motion stops right after the last letter of the word,
  217. while backward motion stops right before the first letter.
  218.    `M-d' (`kill-word') kills the word after point.  To be precise, it
  219. kills everything from point to the place `M-f' would move to.  Thus, if
  220. point is in the middle of a word, `M-d' kills just the part after
  221. point.  If some punctuation comes between point and the next word, it
  222. is killed along with the word.  (If you wish to kill only the next word
  223. but not the punctuation before it, simply do `M-f' to get the end, and
  224. kill the word backwards with `M-DEL'.) `M-d' takes arguments just like
  225. `M-f'.
  226.    `M-DEL' (`backward-kill-word') kills the word before point.  It
  227. kills everything from point back to where `M-b' would move to.  If
  228. point is after the space in `FOO, BAR', then `FOO, ' is killed.  (If
  229. you wish to kill just `FOO', do `M-b M-d' instead of `M-DEL'.)
  230.    `M-t' (`transpose-words') exchanges the word before or containing
  231. point with the following word.  The delimiter characters between the
  232. words do not move.  For example, `FOO, BAR' transposes into `BAR, FOO'
  233. rather than `BAR FOO,'.  *Note Transpose::, for more on transposition
  234. and on arguments to transposition commands.
  235.    To operate on the next N words with an operation which applies
  236. between point and mark, you can either set the mark at point and then
  237. move over the words, or you can use the command `M-@' (`mark-word')
  238. which does not move point, but sets the mark where `M-f' would move to.
  239. `M-@' accepts a numeric argument that says how many words to scan for
  240. the place to put the mark.  In Transient Mark mode, this command
  241. activates the mark.
  242.    The word commands' understanding of syntax is completely controlled
  243. by the syntax table.  Any character can, for example, be declared to be
  244. a word delimiter.  *Note Syntax::.
  245. File: emacs,  Node: Sentences,  Next: Paragraphs,  Prev: Words,  Up: Text
  246. Sentences
  247. =========
  248.    The Emacs commands for manipulating sentences and paragraphs are
  249. mostly on Meta keys, so as to be like the word-handling commands.
  250. `M-a'
  251.      Move back to the beginning of the sentence (`backward-sentence').
  252. `M-e'
  253.      Move forward to the end of the sentence (`forward-sentence').
  254. `M-k'
  255.      Kill forward to the end of the sentence (`kill-sentence').
  256. `C-x DEL'
  257.      Kill back to the beginning of the sentence
  258.      (`backward-kill-sentence').
  259.    The commands `M-a' and `M-e' (`backward-sentence' and
  260. `forward-sentence') move to the beginning and end of the current
  261. sentence, respectively.  They were chosen to resemble `C-a' and `C-e',
  262. which move to the beginning and end of a line.  Unlike them, `M-a' and
  263. `M-e' if repeated or given numeric arguments move over successive
  264. sentences.
  265.    Moving backward over a sentence places point just before the first
  266. character of the sentence; moving forward places point right after the
  267. punctuation that ends the sentence.  Neither one moves over the
  268. whitespace at the sentence boundary.
  269.    Just as `C-a' and `C-e' have a kill command, `C-k', to go with them,
  270. so `M-a' and `M-e' have a corresponding kill command `M-k'
  271. (`kill-sentence') which kills from point to the end of the sentence.
  272. With minus one as an argument it kills back to the beginning of the
  273. sentence.  Larger arguments serve as a repeat count.  There is also a
  274. command, `C-x DEL' (`backward-kill-sentence'), for killing back to the
  275. beginning of a sentence.  This command is useful when you change your
  276. mind in the middle of composing text.
  277.    The sentence commands assume that you follow the American typist's
  278. convention of putting two spaces at the end of a sentence; they consider
  279. a sentence to end wherever there is a `.', `?' or `!' followed by the
  280. end of a line or two spaces, with any number of `)', `]', `'', or `"'
  281. characters allowed in between.  A sentence also begins or ends wherever
  282. a paragraph begins or ends.
  283.    The variable `sentence-end' controls recognition of the end of a
  284. sentence.  It is a regexp that matches the last few characters of a
  285. sentence, together with the whitespace following the sentence.  Its
  286. normal value is
  287.      "[.?!][]\"')]*\\($\\|\t\\|  \\)[ \t\n]*"
  288. This example is explained in the section on regexps.  *Note Regexps::.
  289.    If you want to use just one space between sentences, you should set
  290. `sentence-end' to this value:
  291.      "[.?!][]\"')]*\\($\\|\t\\| \\)[ \t\n]*"
  292. You should also set the variable `sentence-end-double-space' to `nil'
  293. so that the fill commands expect and leave just one space at the end of
  294. a sentence.  Note that this makes it impossible to distinguish between
  295. periods that end sentences and those that indicate abbreviations.
  296. File: emacs,  Node: Paragraphs,  Next: Pages,  Prev: Sentences,  Up: Text
  297. Paragraphs
  298. ==========
  299.    The Emacs commands for manipulating paragraphs are also Meta keys.
  300. `M-{'
  301.      Move back to previous paragraph beginning (`backward-paragraph').
  302. `M-}'
  303.      Move forward to next paragraph end (`forward-paragraph').
  304. `M-h'
  305.      Put point and mark around this or next paragraph
  306.      (`mark-paragraph').
  307.    `M-{' moves to the beginning of the current or previous paragraph,
  308. while `M-}' moves to the end of the current or next paragraph.  Blank
  309. lines and text formatter command lines separate paragraphs and are not
  310. considered part of any paragraph.  Also, an indented line starts a new
  311. paragraph.
  312.    In major modes for programs (as opposed to Text mode), paragraphs
  313. begin and end only at blank lines.  This makes the paragraph commands
  314. continue to be useful even though there are no paragraphs per se.
  315.    When there is a fill prefix, then paragraphs are delimited by all
  316. lines which don't start with the fill prefix.  *Note Filling::.
  317.    When you wish to operate on a paragraph, you can use the command
  318. `M-h' (`mark-paragraph') to set the region around it.  Thus, for
  319. example, `M-h C-w' kills the paragraph around or after point.  The
  320. `M-h' command puts point at the beginning and mark at the end of the
  321. paragraph point was in.  In Transient Mark mode, it activates the mark.
  322. If point is between paragraphs (in a run of blank lines, or at a
  323. boundary), the paragraph following point is surrounded by point and
  324. mark.  If there are blank lines preceding the first line of the
  325. paragraph, one of these blank lines is included in the region.
  326.    The precise definition of a paragraph boundary is controlled by the
  327. variables `paragraph-separate' and `paragraph-start'.  The value of
  328. `paragraph-start' is a regexp that should match any line that either
  329. starts or separates paragraphs.  The value of `paragraph-separate' is
  330. another regexp that should match only lines that separate paragraphs
  331. without being part of any paragraph.  Lines that start a new paragraph
  332. and are contained in it must match only `paragraph-start', not
  333. `paragraph-separate'.  For example, normally `paragraph-start' is `"[
  334. \t\n\f]"' and `paragraph-separate' is `"[ \t\f]*$"'.
  335.    Normally it is desirable for page boundaries to separate paragraphs.
  336. The default values of these variables recognize the usual separator for
  337. pages.
  338. File: emacs,  Node: Pages,  Next: Filling,  Prev: Paragraphs,  Up: Text
  339. Pages
  340. =====
  341.    Files are often thought of as divided into "pages" by the "formfeed"
  342. character (ASCII control-L, octal code 014).  When you print hardcopy
  343. for a file, this character forces a page break; thus, each page of the
  344. file goes on a separate page on paper.  Most Emacs commands treat the
  345. page-separator character just like any other character: you can insert
  346. it with `C-q C-l', and delete it with DEL.  Thus, you are free to
  347. paginate your file or not.  However, since pages are often meaningful
  348. divisions of the file, Emacs provides commands to move over them and
  349. operate on them.
  350. `C-x ['
  351.      Move point to previous page boundary (`backward-page').
  352. `C-x ]'
  353.      Move point to next page boundary (`forward-page').
  354. `C-x C-p'
  355.      Put point and mark around this page (or another page)
  356.      (`mark-page').
  357. `C-x l'
  358.      Count the lines in this page (`count-lines-page').
  359.    The `C-x [' (`backward-page') command moves point to immediately
  360. after the previous page delimiter.  If point is already right after a
  361. page delimiter, it skips that one and stops at the previous one.  A
  362. numeric argument serves as a repeat count.  The `C-x ]' (`forward-page')
  363. command moves forward past the next page delimiter.
  364.    The `C-x C-p' command (`mark-page') puts point at the beginning of
  365. the current page and the mark at the end.  The page delimiter at the
  366. end is included (the mark follows it).  The page delimiter at the front
  367. is excluded (point follows it).  `C-x C-p C-w' is a handy way to kill a
  368. page to move it elsewhere.  If you move to another page delimiter with
  369. `C-x [' and `C-x ]', then yank the killed page, all the pages will be
  370. properly delimited once again.  The reason `C-x C-p' includes only the
  371. following page delimiter in the region is to ensure that.
  372.    A numeric argument to `C-x C-p' is used to specify which page to go
  373. to, relative to the current one.  Zero means the current page.  One
  374. means the next page, and -1 means the previous one.
  375.    The `C-x l' command (`count-lines-page') is good for deciding where
  376. to break a page in two.  It prints in the echo area the total number of
  377. lines in the current page, and then divides it up into those preceding
  378. the current line and those following, as in
  379.      Page has 96 (72+25) lines
  380. Notice that the sum is off by one; this is correct if point is not at
  381. the beginning of a line.
  382.    The variable `page-delimiter' controls where pages begin.  Its value
  383. is a regexp that matches the beginning of a line that separates pages.
  384. The normal value of this variable is `"^\f"', which matches a formfeed
  385. character at the beginning of a line.
  386. File: emacs,  Node: Filling,  Next: Case,  Prev: Pages,  Up: Text
  387. Filling Text
  388. ============
  389.    "Filling" text means breaking it up into lines that fit a specified
  390. width.  Emacs does filling in two ways.  In Auto Fill mode, inserting
  391. text with self-inserting characters also automatically fills it.  There
  392. are also explicit fill commands that you can use when editing text
  393. leaves it unfilled.  When you edit formatted text, you can specify a
  394. style of filling for each portion of the text (*note Formatted Text::.).
  395. * Menu:
  396. * Auto Fill::      Auto Fill mode breaks long lines automatically.
  397. * Fill Commands:: Commands to refill paragraphs and center lines.
  398. * Fill Prefix::      Filling when every line is indented or in a comment, etc.
  399. File: emacs,  Node: Auto Fill,  Next: Fill Commands,  Up: Filling
  400. Auto Fill Mode
  401. --------------
  402.    "Auto Fill" mode is a minor mode in which lines are broken
  403. automatically when they become too wide.  Breaking happens only when
  404. you type a SPC or RET.
  405. `M-x auto-fill-mode'
  406.      Enable or disable Auto Fill mode.
  407. `SPC'
  408. `RET'
  409.      In Auto Fill mode, break lines when appropriate.
  410.    `M-x auto-fill-mode' turns Auto Fill mode on if it was off, or off
  411. if it was on.  With a positive numeric argument it always turns Auto
  412. Fill mode on, and with a negative argument always turns it off.  You can
  413. see when Auto Fill mode is in effect by the presence of the word `Fill'
  414. in the mode line, inside the parentheses.  Auto Fill mode is a minor
  415. mode which is enabled or disabled for each buffer individually.  *Note
  416. Minor Modes::.
  417.    In Auto Fill mode, lines are broken automatically at spaces when
  418. they get longer than the desired width.  Line breaking and
  419. rearrangement takes place only when you type SPC or RET.  If you wish
  420. to insert a space or newline without permitting line-breaking, type
  421. `C-q SPC' or `C-q LFD' (recall that a newline is really a linefeed).
  422. Also, `C-o' inserts a newline without line breaking.
  423.    Auto Fill mode works well with Lisp mode, because when it makes a new
  424. line in Lisp mode it indents that line with TAB.  If a line ending in a
  425. comment gets too long, the text of the comment is split into two
  426. comment lines.  Optionally new comment delimiters are inserted at the
  427. end of the first line and the beginning of the second so that each line
  428. is a separate comment; the variable `comment-multi-line' controls the
  429. choice (*note Comments::.).
  430.    Adaptive filling (see the following section) works for Auto Filling
  431. as well as for explicit fill commands.  It takes a fill prefix
  432. automatically from the second or first line of a paragraph.
  433.    Auto Fill mode does not refill entire paragraphs; it can break lines
  434. but cannot merge lines.  So editing in the middle of a paragraph can
  435. result in a paragraph that is not correctly filled.  The easiest way to
  436. make the paragraph properly filled again is usually with the explicit
  437. fill commands.  *Note Fill Commands::.
  438.    Many users like Auto Fill mode and want to use it in all text files.
  439. The section on init files says how to arrange this permanently for
  440. yourself.  *Note Init File::.
  441. File: emacs,  Node: Fill Commands,  Next: Fill Prefix,  Prev: Auto Fill,  Up: Filling
  442. Explicit Fill Commands
  443. ----------------------
  444. `M-q'
  445.      Fill current paragraph (`fill-paragraph').
  446. `C-x f'
  447.      Set the fill column (`set-fill-column').
  448. `M-x fill-region'
  449.      Fill each paragraph in the region (`fill-region').
  450. `M-x fill-region-as-paragraph.'
  451.      Fill the region, considering it as one paragraph.
  452. `M-s'
  453.      Center a line.
  454.    To refill a paragraph, use the command `M-q' (`fill-paragraph').
  455. This operates on the paragraph that point is inside, or the one after
  456. point if point is between paragraphs.  Refilling works by removing all
  457. the line-breaks, then inserting new ones where necessary.
  458.    To refill many paragraphs, use `M-x fill-region', which divides the
  459. region into paragraphs and fills each of them.
  460.    `M-q' and `fill-region' use the same criteria as `M-h' for finding
  461. paragraph boundaries (*note Paragraphs::.).  For more control, you can
  462. use `M-x fill-region-as-paragraph', which refills everything between
  463. point and mark.  This command deletes any blank lines within the
  464. region, so separate blocks of text end up combined into one block.
  465.    A numeric argument to `M-q' causes it to "justify" the text as well
  466. as filling it.  This means that extra spaces are inserted to make the
  467. right margin line up exactly at the fill column.  To remove the extra
  468. spaces, use `M-q' with no argument.  (Likewise for `fill-region'.)
  469. Another way to control justification, and choose other styles of
  470. filling, is with the `justification' text property; see *Note Format
  471. Justification::.
  472.    The fill commands can deduce the proper fill prefix for a paragraph
  473. automatically in certain cases: either whitespace or certain punctuation
  474. characters at the beginning of a line are treated as a fill prefix.
  475. They take the fill prefix from the paragraph's second line, unless the
  476. paragraph has just one line.  You can turn off this feature by setting
  477. `adaptive-fill-mode' to `nil'.
  478.    Some major modes, including Text mode, treat whitespace at the
  479. beginning of a line as a signal that this line starts a new paragraph.
  480. It would be a mistake to copy text which implies the start of a
  481. paragraph onto each line of the paragraph when filling it.  Therefore,
  482. adaptive filling does not accept a fill prefix from a line which is a
  483. paragraph-starter.  In particular, adaptive filling in Text mode does
  484. not accept a fill prefix consisting of just whitespace.
  485.    However, other modes including Indented Text mode (*note Text
  486. Mode::.) do not consider whitespace as a signal to start a new
  487. paragraph.  In these modes, adaptive filling does accept a fill prefix
  488. consisting of just whitespace, if the first or second line of a
  489. paragraph begins with whitespace.
  490.    The variable `adaptive-fill-regexp' determines what kinds of line
  491. beginnings can serve as a fill prefix: any characters at the start of
  492. the line which match this regular expression are used.
  493.    You can specify more complex ways of choosing a fill prefix
  494. automatically by setting the variable `adaptive-fill-function' to a
  495. function.  This function is called with point after the left margin of a
  496. line, and it should return the appropriate fill prefix based on that
  497. line.  If it returns `nil', that means it sees no fill prefix in that
  498. line.
  499.    The command `M-s' (`center-line') centers the current line within
  500. the current fill column.  With an argument N, it centers N lines
  501. individually and moves past them.
  502.    The maximum line width for filling is in the variable `fill-column'.
  503. Altering the value of `fill-column' makes it local to the current
  504. buffer; until that time, the default value is in effect.  The default
  505. is initially 70.  *Note Locals::.  The easiest way to set `fill-column'
  506. is to use the command `C-x f' (`set-fill-column').  With a numeric
  507. argument, it uses that as the new fill column.  With just `C-u' as
  508. argument, it sets `fill-column' to the current horizontal position of
  509. point.
  510.    Emacs commands normally consider a period followed by two spaces or
  511. by a newline as the end of a sentence; a period followed by just one
  512. space indicates an abbreviation and not the end of a sentence.  To
  513. preserve the distinction between these two ways of using a period, the
  514. fill commands do not break a line after a period followed by just one
  515. space.
  516.    If the variable `sentence-end-double-space' is `nil', the fill
  517. commands expect and leave just one space at the end of a sentence.
  518. Ordinarily this variable is `t', so the fill commands insist on two
  519. spaces for the end of a sentence, as explained above.  *Note
  520. Sentences::.
  521.    If the variable `colon-double-space' is non-`nil', the fill commands
  522. put two spaces after a colon.
  523. File: emacs,  Node: Fill Prefix,  Prev: Fill Commands,  Up: Filling
  524. The Fill Prefix
  525. ---------------
  526.    To fill a paragraph in which each line starts with a special marker
  527. (which might be a few spaces, giving an indented paragraph), use the
  528. "fill prefix" feature.  The fill prefix is a string which Emacs expects
  529. every line to start with, and which is not included in filling.
  530. `C-x .'
  531.      Set the fill prefix (`set-fill-prefix').
  532. `M-q'
  533.      Fill a paragraph using current fill prefix (`fill-paragraph').
  534. `M-x fill-individual-paragraphs'
  535.      Fill the region, considering each change of indentation as
  536.      starting a new paragraph.
  537. `M-x fill-nonuniform-paragraphs'
  538.      Fill the region, considering only paragraph-separator lines as
  539.      starting a new paragraph.
  540.    To specify a fill prefix, move to a line that starts with the desired
  541. prefix, put point at the end of the prefix, and give the command
  542. `C-x .' (`set-fill-prefix').  That's a period after the `C-x'.  To turn
  543. off the fill prefix, specify an empty prefix: type `C-x .' with point
  544. at the beginning of a line.
  545.    When a fill prefix is in effect, the fill commands remove the fill
  546. prefix from each line before filling and insert it on each line after
  547. filling.  Auto Fill mode also inserts the fill prefix automatically when
  548. it makes a new line.  The `C-o' command inserts the fill prefix on new
  549. lines it creates, when you use it at the beginning of a line (*note
  550. Blank Lines::.).  Conversely, the command `M-^' deletes the prefix (if
  551. it occurs) after the newline that it deletes (*note Indentation::.).
  552.    For example, if `fill-column' is 40 and you set the fill prefix to
  553. `;; ', then `M-q' in the following text
  554.      ;; This is an
  555.      ;; example of a paragraph
  556.      ;; inside a Lisp-style comment.
  557. produces this:
  558.      ;; This is an example of a paragraph
  559.      ;; inside a Lisp-style comment.
  560.    Lines that do not start with the fill prefix are considered to start
  561. paragraphs, both in `M-q' and the paragraph commands; this gives good
  562. results for paragraphs with hanging indentation (every line indented
  563. except the first one).  Lines which are blank or indented once the
  564. prefix is removed also separate or start paragraphs; this is what you
  565. want if you are writing multi-paragraph comments with a comment
  566. delimiter on each line.
  567.    You can use `M-x fill-individual-paragraphs' to set the fill prefix
  568. for each paragraph automatically.  This command divides the region into
  569. paragraphs, treating every change in the amount of indentation as the
  570. start of a new paragraph, and fills each of these paragraphs.  Thus,
  571. all the lines in one "paragraph" have the same amount of indentation.
  572. That indentation serves as the fill prefix for that paragraph.
  573.    `M-x fill-nonuniform-paragraphs' is a similar command that divides
  574. the region into paragraphs in a different way.  It considers only
  575. paragraph-separating lines (as defined by `paragraph-separate') as
  576. starting a new paragraph.  Since this means that the lines of one
  577. paragraph may have different amounts of indentation, the fill prefix
  578. used is the smallest amount of indentation of any of the lines of the
  579. paragraph.  This gives good results with styles that indent a
  580. paragraph's first line more or less that the rest of the paragraph.
  581.    The fill prefix is stored in the variable `fill-prefix'.  Its value
  582. is a string, or `nil' when there is no fill prefix.  This is a
  583. per-buffer variable; altering the variable affects only the current
  584. buffer, but there is a default value which you can change as well.
  585. *Note Locals::.
  586.    The `indentation' text property provides another way to control the
  587. amount of indentation paragraphs receive.  *Note Format Indentation::.
  588. File: emacs,  Node: Case,  Next: Text Mode,  Prev: Filling,  Up: Text
  589. Case Conversion Commands
  590. ========================
  591.    Emacs has commands for converting either a single word or any
  592. arbitrary range of text to upper case or to lower case.
  593. `M-l'
  594.      Convert following word to lower case (`downcase-word').
  595. `M-u'
  596.      Convert following word to upper case (`upcase-word').
  597. `M-c'
  598.      Capitalize the following word (`capitalize-word').
  599. `C-x C-l'
  600.      Convert region to lower case (`downcase-region').
  601. `C-x C-u'
  602.      Convert region to upper case (`upcase-region').
  603.    The word conversion commands are the most useful.  `M-l'
  604. (`downcase-word') converts the word after point to lower case, moving
  605. past it.  Thus, repeating `M-l' converts successive words.  `M-u'
  606. (`upcase-word') converts to all capitals instead, while `M-c'
  607. (`capitalize-word') puts the first letter of the word into upper case
  608. and the rest into lower case.  All these commands convert several words
  609. at once if given an argument.  They are especially convenient for
  610. converting a large amount of text from all upper case to mixed case,
  611. because you can move through the text using `M-l', `M-u' or `M-c' on
  612. each word as appropriate, occasionally using `M-f' instead to skip a
  613. word.
  614.    When given a negative argument, the word case conversion commands
  615. apply to the appropriate number of words before point, but do not move
  616. point.  This is convenient when you have just typed a word in the wrong
  617. case: you can give the case conversion command and continue typing.
  618.    If a word case conversion command is given in the middle of a word,
  619. it applies only to the part of the word which follows point.  This is
  620. just like what `M-d' (`kill-word') does.  With a negative argument,
  621. case conversion applies only to the part of the word before point.
  622.    The other case conversion commands are `C-x C-u' (`upcase-region')
  623. and `C-x C-l' (`downcase-region'), which convert everything between
  624. point and mark to the specified case.  Point and mark do not move.
  625.    The region case conversion commands `upcase-region' and
  626. `downcase-region' are normally disabled.  This means that they ask for
  627. confirmation if you try to use them.  When you confirm, you may enable
  628. the command, which means it will not ask for confirmation again.  *Note
  629. Disabling::.
  630. File: emacs,  Node: Text Mode,  Next: Outline Mode,  Prev: Case,  Up: Text
  631. Text Mode
  632. =========
  633.    When you edit files of text in a human language, it's more convenient
  634. to use Text mode rather than Fundamental mode.  Invoke `M-x text-mode'
  635. to enter Text mode.  In Text mode, TAB runs the function
  636. `tab-to-tab-stop', which allows you to use arbitrary tab stops set with
  637. `M-x edit-tab-stops' (*note Tab Stops::.).  Features concerned with
  638. comments in programs are turned off in Text mode except when explicitly
  639. invoked.  The syntax table is changed so that periods are not
  640. considered part of a word, while apostrophes, backspaces and underlines
  641. are part of words.
  642.    A similar variant mode is Indented Text mode, intended for editing
  643. text in which most lines are indented.  This mode defines TAB to run
  644. `indent-relative' (*note Indentation::.), and makes Auto Fill indent
  645. the lines it creates.  The result is that normally a line made by Auto
  646. Filling, or by LFD, is indented just like the previous line.  In
  647. Indented Text mode, only blank lines separate paragraphs--indented
  648. lines continue the current paragraph.  Use `M-x indented-text-mode' to
  649. select this mode.
  650.    Text mode, and all the modes based on it, define `M-TAB' as the
  651. command `ispell-complete-word', which performs completion of the
  652. partial word in the buffer before point, using the spelling dictionary
  653. as the space of possible words.  *Note Spelling::.
  654.    Entering Text mode or Indented Text mode runs the hook
  655. `text-mode-hook'.  Other major modes related to Text mode also run this
  656. hook, followed by hooks of their own; this includes Nroff mode, TeX
  657. mode, Outline mode and Mail mode.  Hook functions on `text-mode-hook'
  658. can look at the value of `major-mode' to see which of these modes is
  659. actually being entered.  *Note Hooks::.
  660.    Emacs provides two other modes for editing text that is to be passed
  661. through a text formatter to produce fancy formatted printed output.
  662. *Note Nroff Mode::, for editing input to the formatter nroff.  *Note
  663. TeX Mode::, for editing input to the formatter TeX.
  664.    Another mode is used for editing outlines.  It allows you to view the
  665. text at various levels of detail.  You can view either the outline
  666. headings alone or both headings and text; you can also hide some of the
  667. headings at lower levels from view to make the high level structure more
  668. visible.  *Note Outline Mode::.
  669. File: emacs,  Node: Outline Mode,  Next: TeX Mode,  Prev: Text Mode,  Up: Text
  670. Outline Mode
  671. ============
  672.    Outline mode is a major mode much like Text mode but intended for
  673. editing outlines.  It allows you to make parts of the text temporarily
  674. invisible so that you can see the outline structure.  Type `M-x
  675. outline-mode' to switch to Outline mode as the major mode of the current
  676. buffer.
  677.    When Outline mode makes a line invisible, the line does not appear on
  678. the screen.  The screen appears exactly as if the invisible line were
  679. deleted, except that an ellipsis (three periods in a row) appears at the
  680. end of the previous visible line (only one ellipsis no matter how many
  681. invisible lines follow).
  682.    All editing commands treat the text of the invisible line as part of
  683. the previous visible line.  For example, `C-n' moves onto the next
  684. visible line.  Killing an entire visible line, including its
  685. terminating newline, really kills all the following invisible lines
  686. along with it; yanking it all back yanks the invisible lines and they
  687. remain invisible.
  688.    Outline minor mode provides the same commands as the major mode,
  689. Outline mode, but you can use it in conjunction with other major modes.
  690. Type `M-x outline-minor-mode' to enable the Outline minor mode in the
  691. current buffer.  You can also specify this in the text of a file, with
  692. a file local variable of the form `mode: outline-minor' (*note File
  693. Variables::.).
  694.    The major mode, Outline mode, provides special key bindings on the
  695. `C-c' prefix.  Outline minor mode provides similar bindings with `C-c
  696. @' as the prefix; this is to reduce the conflicts with the major mode's
  697. special commands.  (The variable `outline-minor-mode-prefix' controls
  698. the prefix used.)
  699.    Entering Outline mode runs the hook `text-mode-hook' followed by the
  700. hook `outline-mode-hook' (*note Hooks::.).
  701. * Menu:
  702. * Format: Outline Format.       What the text of an outline looks like.
  703. * Motion: Outline Motion.       Special commands for moving through
  704.                                      outlines.
  705. * Visibility: Outline Visibility.  Commands to control what is visible.
  706. * Views: Outline Views.            Outlines and multiple views.
  707. File: emacs,  Node: Outline Format,  Next: Outline Motion,  Up: Outline Mode
  708. Format of Outlines
  709. ------------------
  710.    Outline mode assumes that the lines in the buffer are of two types:
  711. "heading lines" and "body lines".  A heading line represents a topic in
  712. the outline.  Heading lines start with one or more stars; the number of
  713. stars determines the depth of the heading in the outline structure.
  714. Thus, a heading line with one star is a major topic; all the heading
  715. lines with two stars between it and the next one-star heading are its
  716. subtopics; and so on.  Any line that is not a heading line is a body
  717. line.  Body lines belong with the preceding heading line.  Here is an
  718. example:
  719.      * Food
  720.      
  721.      This is the body,
  722.      which says something about the topic of food.
  723.      
  724.      ** Delicious Food
  725.      
  726.      This is the body of the second-level header.
  727.      
  728.      ** Distasteful Food
  729.      
  730.      This could have
  731.      a body too, with
  732.      several lines.
  733.      
  734.      *** Dormitory Food
  735.      
  736.      * Shelter
  737.      
  738.      Another first-level topic with its header line.
  739.    A heading line together with all following body lines is called
  740. collectively an "entry".  A heading line together with all following
  741. deeper heading lines and their body lines is called a "subtree".
  742.    You can customize the criterion for distinguishing heading lines by
  743. setting the variable `outline-regexp'.  Any line whose beginning has a
  744. match for this regexp is considered a heading line.  Matches that start
  745. within a line (not at the left margin) do not count.  The length of the
  746. matching text determines the level of the heading; longer matches make
  747. a more deeply nested level.  Thus, for example, if a text formatter has
  748. commands `@chapter', `@section' and `@subsection' to divide the
  749. document into chapters and sections, you could make those lines count
  750. as heading lines by setting `outline-regexp' to
  751. `"@chap\\|@\\(sub\\)*section"'.  Note the trick: the two words
  752. `chapter' and `section' are equally long, but by defining the regexp to
  753. match only `chap' we ensure that the length of the text matched on a
  754. chapter heading is shorter, so that Outline mode will know that
  755. sections are contained in chapters.  This works as long as no other
  756. command starts with `@chap'.
  757.    It is possible to change the rule for calculating the level of a
  758. heading line by setting the variable `outline-level'.  The value of
  759. `outline-level' should be a function that takes no arguments and
  760. returns the level of the current heading.  Some major modes such as C,
  761. Nroff, and Emacs Lisp mode set this variable in order to work with
  762. Outline minor mode.
  763.    Outline mode makes a line invisible by changing the newline before it
  764. into an ASCII control-M (code 015).  Most editing commands that work on
  765. lines treat an invisible line as part of the previous line because,
  766. strictly speaking, it *is* part of that line, since there is no longer a
  767. newline in between.  When you save the file in Outline mode, control-M
  768. characters are saved as newlines, so the invisible lines become ordinary
  769. lines in the file.  But saving does not change the visibility status of
  770. a line inside Emacs.
  771. File: emacs,  Node: Outline Motion,  Next: Outline Visibility,  Prev: Outline Format,  Up: Outline Mode
  772. Outline Motion Commands
  773. -----------------------
  774.    Outline mode provides special motion commands that move backward and
  775. forward to heading lines.
  776. `C-c C-n'
  777.      Move point to the next visible heading line
  778.      (`outline-next-visible-heading').
  779. `C-c C-p'
  780.      Move point to the previous visible heading line
  781.      (`outline-previous-visible-heading').
  782. `C-c C-f'
  783.      Move point to the next visible heading line at the same level as
  784.      the one point is on (`outline-forward-same-level').
  785. `C-c C-b'
  786.      Move point to the previous visible heading line at the same level
  787.      (`outline-backward-same-level').
  788. `C-c C-u'
  789.      Move point up to a lower-level (more inclusive) visible heading
  790.      line (`outline-up-heading').
  791.    `C-c C-n' (`outline-next-visible-heading') moves down to the next
  792. heading line.  `C-c C-p' (`outline-previous-visible-heading') moves
  793. similarly backward.  Both accept numeric arguments as repeat counts.
  794. The names emphasize that invisible headings are skipped, but this is
  795. not really a special feature.  All editing commands that look for lines
  796. ignore the invisible lines automatically.
  797.    More powerful motion commands understand the level structure of
  798. headings.  `C-c C-f' (`outline-forward-same-level') and `C-c C-b'
  799. (`outline-backward-same-level') move from one heading line to another
  800. visible heading at the same depth in the outline.  `C-c C-u'
  801. (`outline-up-heading') moves backward to another heading that is less
  802. deeply nested.
  803. File: emacs,  Node: Outline Visibility,  Next: Outline Views,  Prev: Outline Motion,  Up: Outline Mode
  804. Outline Visibility Commands
  805. ---------------------------
  806.    The other special commands of outline mode are used to make lines
  807. visible or invisible.  Their names all start with `hide' or `show'.
  808. Most of them fall into pairs of opposites.  They are not undoable;
  809. instead, you can undo right past them.  Making lines visible or
  810. invisible is simply not recorded by the undo mechanism.
  811. `C-c C-t'
  812.      Make all body lines in the buffer invisible (`hide-body').
  813. `C-c C-a'
  814.      Make all lines in the buffer visible (`show-all').
  815. `C-c C-d'
  816.      Make everything under this heading invisible, not including this
  817.      heading itself
  818.      (`hide-subtree').
  819. `C-c C-s'
  820.      Make everything under this heading visible, including body,
  821.      subheadings, and their bodies (`show-subtree').
  822. `C-c C-l'
  823.      Make the body of this heading line, and of all its subheadings,
  824.      invisible (`hide-leaves').
  825. `C-c C-k'
  826.      Make all subheadings of this heading line, at all levels, visible
  827.      (`show-branches').
  828. `C-c C-i'
  829.      Make immediate subheadings (one level down) of this heading line
  830.      visible (`show-children').
  831. `C-c C-c'
  832.      Make this heading line's body invisible (`hide-entry').
  833. `C-c C-e'
  834.      Make this heading line's body visible (`show-entry').
  835. `C-c C-q'
  836.      Hide everything except the top N levels of heading lines
  837.      (`hide-sublevels').
  838. `C-c C-o'
  839.      Hide everything except for the heading or body that point is in,
  840.      plus the headings leading up from there to the top level of the
  841.      outline (`hide-other').
  842.    Two commands that are exact opposites are `C-c C-c' (`hide-entry')
  843. and `C-c C-e' (`show-entry').  They are used with point on a heading
  844. line, and apply only to the body lines of that heading.  Subheadings
  845. and their bodies are not affected.
  846.    Two more powerful opposites are `C-c C-d' (`hide-subtree') and `C-c
  847. C-s' (`show-subtree').  Both expect to be used when point is on a
  848. heading line, and both apply to all the lines of that heading's
  849. "subtree": its body, all its subheadings, both direct and indirect, and
  850. all of their bodies.  In other words, the subtree contains everything
  851. following this heading line, up to and not including the next heading of
  852. the same or higher rank.
  853.    Intermediate between a visible subtree and an invisible one is having
  854. all the subheadings visible but none of the body.  There are two
  855. commands for doing this, depending on whether you want to hide the
  856. bodies or make the subheadings visible.  They are `C-c C-l'
  857. (`hide-leaves') and `C-c C-k' (`show-branches').
  858.    A little weaker than `show-branches' is `C-c C-i' (`show-children').
  859. It makes just the direct subheadings visible--those one level down.
  860. Deeper subheadings remain invisible, if they were invisible.
  861.    Two commands have a blanket effect on the whole file.  `C-c C-t'
  862. (`hide-body') makes all body lines invisible, so that you see just the
  863. outline structure.  `C-c C-a' (`show-all') makes all lines visible.
  864. These commands can be thought of as a pair of opposites even though
  865. `C-c C-a' applies to more than just body lines.
  866.    The command `C-c C-q' (`hide-sublevels') hides all but the top level
  867. headings.  With a numeric argument N, it hides everything except the
  868. top N levels of heading lines.
  869.    The command `C-c C-o' (`hide-other') hides everything except the
  870. heading or body text that point is in, plus its parents (the headers
  871. leading up from there to top level in the outline).
  872.    You can turn off the use of ellipses at the ends of visible lines by
  873. setting `selective-display-ellipses' to `nil'.  Then there is no
  874. visible indication of the presence of invisible lines.
  875. File: emacs,  Node: Outline Views,  Prev: Outline Visibility,  Up: Outline Mode
  876. Viewing One Outline in Multiple Views
  877. -------------------------------------
  878.    You can display two views of a single outline at the same time, in
  879. different windows, by means of an alternative implementation of Outline
  880. mode called `noutline'.
  881.    To do this, first load the library `noutline' with `M-x load-library
  882. RET noutline RET'.  This loads the alternative implementation of
  883. Outline mode.  It provides the same command names and key bindings as
  884. regular Outline mode, but it implements them differently.
  885.    Then, to display a second view of an outline buffer, you must create
  886. an indirect buffer using `M-x make-indirect-buffer'.  The first
  887. argument of this command is the existing outline buffer name, and its
  888. second argument is the name to use for the new indirect buffer.  *Note
  889. Indirect Buffers::.
  890.    Once the indirect buffer exists, you can display it in a window in
  891. the normal fashion, with `C-x 4 b' or other Emacs commands.  The Outline
  892. mode commands to show and hide parts of the text operate on each buffer
  893. independently; as a result, each buffer can have its own view.  If you
  894. want more than two views on the same outline, create additional indirect
  895. buffers.
  896.    In a future Emacs version, the alternative `noutline' implementation
  897. will probably become the principal implementation.
  898.